package es.abredatos.client.view;

import java.util.List;

import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;

import es.abredatos.client.presenter.BooksPresenter;

public class BooksView extends Composite implements BooksPresenter.Display {

	private Label viewTitle;
	private FlexTable fTable;
	private Button newSearchButton;
	private VerticalPanel vpanel;

	public BooksView() {

		viewTitle = new Label(getClass().getName());

		fTable = new FlexTable();

		newSearchButton = new Button("Nueva busqueda");

		VerticalPanel vPanel = new VerticalPanel();
		vPanel.add(viewTitle);
		vPanel.add(fTable);
		vPanel.add(newSearchButton);

		initWidget(vPanel);
	}

	public void setRows(List<String> rows) {
		for (int i = 0; i < rows.size(); i++) {
			fTable.setText(i, 0, rows.get(i));
		}
	}

	public HasClickHandlers getSelectedItem() {
		return fTable;
	}

	public HasClickHandlers getNewSearchButton() {
		return newSearchButton;
	}

}
